package com.hdu.dwh.service.impl.model_impl;

import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdu.dwh.mapper.model_mapper.MetaTableMapper;
import com.hdu.dwh.pojos.model_pojos.MetaTable;
import com.hdu.dwh.pojos.source_access_pojos.DataWarehouseTable;
import com.hdu.dwh.service.DataWarehouseTableService;
import com.hdu.dwh.service.model_service.MetaTableService;

@Service
public class MetaTableServiceImpl extends ServiceImpl<MetaTableMapper, MetaTable> implements MetaTableService {
    @Autowired
    private DataWarehouseTableService dwhTableService;
    
    @Override
    public MetaTable createMetaTable(MetaTable metaTable, Long modelId, String type) throws IllegalAccessException, InvocationTargetException {
        // 获取源表信息
        DataWarehouseTable sourceTable = this.dwhTableService.getById(metaTable.getSourceTableId());

        // 创建MetaTable
        MetaTable _metaTable = new MetaTable(sourceTable, type, modelId);
        this.save(_metaTable);
        metaTable.setName(_metaTable.getName());
    
        return _metaTable;
    }
}
